package leecode;
class Node{
     int val;
     int min;
     Node next;
    public Node(int val, int min, Node next) {

        this.val = val;
        this.min = min;
        this.next = next;
    }
}
 class MinStack {
    Node head;
    public MinStack() {

    }

    public void push(int x) {
        if(head==null){
            head=new Node(x,x,null);
        }else {
            head.next=new Node(x,Math.min(x,head.min),null);
            head=head.next;
        }

    }

    public void pop() {
        head.next=null;
    }

    public int top() {
        return head.val;
    }

    public int min() {
        return head.min;
    }
}
public class leetcode2 {
    public static void main(String[] args) {
     MinStack minStack=new MinStack();
     minStack.push(5);
     minStack.push(6);
     int a=minStack.min();
        System.out.println(a);
    }
}
